﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using System.Web.Security;
using BLL;
using Entity;

namespace Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Ok_Click(object sender, EventArgs e)
        {
            try
            {
                SitePrincipal newUser = SitePrincipal.ValidateLogin(Email.Text.Trim(), Password.Text.Trim());
                Context.User = newUser;
                FormsAuthentication.SetAuthCookie(Email.Text.Trim(), false);
                FormsAuthentication.RedirectFromLoginPage(Email.Text.Trim(), false); 
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('"+ex.Message+"')</script>");
            }
        }
    }
}